#include "mainwindow.h"

#include <QApplication>
#include <QFile>
#include <QtGui/QSurfaceFormat>

#include "BaseControl/Font/YunXiuIconFont.h"


int main(int argc, char *argv[])
{
    // 设置高dpi
#if defined(Q_OS_WIN)
    qputenv("QT_MULTIMEDIA_PREFERRED_PLUGINS", "windowsmediafoundation");

    QApplication::setAttribute(Qt::AA_DisableShaderDiskCache);
    QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif

#ifdef __APPLE__
    QApplication::setAttribute(Qt::AA_DisableShaderDiskCache);

    QSurfaceFormat format;
    format.setVersion(4, 1);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setColorSpace(QSurfaceFormat::sRGBColorSpace);
    QSurfaceFormat::setDefaultFormat(format);
#endif
#ifdef QT_VERSION_6
    QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor);
#endif

#ifdef Q_OS_MACOS
    QFont font("PingFang");
#elif defined(Q_OS_WIN)
    QFont font("Microsoft YaHei");
#endif
    font.setStyleStrategy(QFont::PreferAntialias);
    font.setHintingPreference(QFont::PreferNoHinting);
    QApplication::setFont(font);

    QApplication a(argc, argv);

    QFile qss(":/Qss/Resource/DarkStyle.qss");
    qss.open(QFile::ReadOnly);
    a.setStyleSheet(qss.readAll());
    qss.close();

    YunXiuIconFont::instance();

    MainWindow w;
    w.show();
    return a.exec();
}
